#include <workflow/WFTaskFactory.h>
#include <workflow/WFFacilities.h>
#include <stdio.h>
#include <signal.h>

WFFacilities::WaitGroup waitGroup(10);


void handler(int) {
    waitGroup.done();
    printf("done\n");
}

void callBack(WFHttpTask *task) {
    const void *body;
    size_t size;
    task->get_resp()->get_parsed_body(&body, &size);
    printf("%s\n", (const char *) body);
}

int main(void) {
    signal(SIGINT, handler);

    auto func = std::bind(&callBack, std::placeholders::_1);
    WFHttpTask *task =
            WFTaskFactory::create_http_task("http://www.baidu.com", 10, 10, func);

    task->start();
    waitGroup.wait();
    return 0;
}

